package com.z.pms1.dao.impl;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.z.pms1.dao.LoginDao;
import com.z.pms1.model.C_user;

/**
 * @author 
 *
 */
@Repository("loginDao")
public class LoginDaoImpl implements LoginDao {

	@Autowired
	private SessionFactory sessionFactory;

//	private Session getCurrentSession() {
//		return sessionFactory.openSession();
//	}
	
	//TODO ADD transaction control
	public C_user find(String user_id) {
		Session session = sessionFactory.openSession();
		Query query = session.createQuery("SELECT u FROM C_user u WHERE u.user_id=" + user_id);
		C_user c_user = (C_user) query.uniqueResult();
		session.close();
		return c_user;
	}

}
